package zhu.areas.match.service;

import java.util.List;

import zhu.areas.match.dao.ICompAppDAO;
import zhu.areas.match.dao.ICompResultDAO;
import zhu.areas.match.data.CompApp;
import zhu.areas.match.data.CompResult;
import zhu.areas.match.data.MatchStatue;
import zhu.common.data.PageBean;
import zhu.common.data.Pager;

public class CompAppServiceImpl implements ICompAppService {

	private ICompAppDAO compAppDAO;
	private ICompResultDAO compResultDAO;

	
	public void setCompResultDAO(ICompResultDAO compResultDAO) {
		this.compResultDAO = compResultDAO;
	}

	public void updateCompApp(CompApp compApp) {
		compAppDAO.updateCompApp(compApp);
		
	}
	
	public List<CompApp> findAllCompApp() {
		return compAppDAO.findAllCompApp();
	}

	public CompApp findCompAppById(Integer id) {
		return this.compAppDAO.findCompAppById(id);
	}

	public List<CompApp> findCompAppByStatue(int statueId) {
		return compAppDAO.findCompAppByStatue(statueId);
	}

	public int  pubAllPassedComp(){
		return compAppDAO.pubAllPassedComp();
	}
	
	public ICompAppDAO getCompAppDAO() {
		return compAppDAO;
	}

	public void setCompAppDAO(ICompAppDAO compAppDAO) {
		this.compAppDAO = compAppDAO;
	}

	public void setCompOutDate(int compId) {
		CompApp compApp=compAppDAO.findCompAppById(compId);
		compApp.setStatue(new MatchStatue(6));
		compAppDAO.updateCompApp(compApp);
		
	}

	public Pager queryForPage(Integer statue, Integer pageSize,
			String currentPage, String pageMethod) {
		return this.compAppDAO.findCompListByStatue(statue, pageSize, currentPage, pageMethod);
	}

	public Pager findCompResultAsPager(Integer pageSize, String currentPage,
			String pageMethod) {		
		return compResultDAO.findResultsAsPager(pageSize, currentPage, pageMethod);
	}

	public void saveCompApp(CompApp compApp) {
		compAppDAO.save(compApp);

	}

	public ICompResultDAO getCompResultDAO() {
		return compResultDAO;
	}

	public CompResult findCompResultByID(int compID) {
		
		return compResultDAO.findResultByCompID(compID);
	}

	

}
